#include "kzfqgraphicsrectitem.h"
#include <QGraphicsSceneMouseEvent>
#include <QDebug>

kzfQGraphicsRectItem::kzfQGraphicsRectItem(QGraphicsRectItem *parent)
    : QGraphicsRectItem{parent}
{


}

kzfQGraphicsRectItem::kzfQGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent)
    : QGraphicsRectItem{rect, parent}
{


}
kzfQGraphicsRectItem::kzfQGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent)
    : QGraphicsRectItem{x, y, w, h, parent}
{


}

//-------------------------------------------------------------------------------
void kzfQGraphicsRectItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    QGraphicsItem::mousePressEvent(event);

    // qDebug("item mouse press");
    // qDebug()<<isActive();
    // setActive(!isActive());//点击选中,再点击取消
    update();
}

void kzfQGraphicsRectItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    QGraphicsItem::mouseMoveEvent(event);

    // qDebug("item mouse move");
    // if (event->modifiers() & Qt::ShiftModifier) {
    //     // stuff << event->pos();
    //     qDebug()<<event->pos();
    //     update();
    //     return;
    // }

    update();
}

void kzfQGraphicsRectItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    QGraphicsItem::mouseReleaseEvent(event);

    // setActive(false);
    // qDebug("item mouse release");

    update();
}
